# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Philipp Überbacher <hollunder at gmx dot at>

pkgname=qtractor
pkgver=0.9.33
pkgrel=1
pkgdesc="Audio/MIDI multitrack sequencer"
arch=(loong64 x86_64)
url="https://qtractor.sourceforge.io/"
license=(GPL2)
groups=(pro-audio)
depends=(
  gcc-libs
  glibc
  hicolor-icon-theme
  libmad
  libxcb
  qt6-base
  qt6-svg
  zlib
)
makedepends=(
  alsa-lib
  aubio
  clap
  cmake
  dssi
  jack
  ladspa
  liblo
  libogg
  libsamplerate
  libsndfile
  libvorbis
  lilv
  lv2
  qt6-tools
  rubberband
  suil
  vst3sdk
)
optdepends=(
  'new-session-manager: for session management'
  'qt6-wayland: for native wayland support'
)
provides=(
  clap-host
  dssi-host
  ladspa-host
  lv2-host
  vst-host
  vst3-host
)
source=(https://github.com/rncbc/$pkgname/archive/refs/tags/${pkgname}_${pkgver//./_}.tar.gz)
sha512sums=('6314ae10020168f43b73c542e86bcb1ea5b088072930bfa4f2e8b89013e05a28af5de88ec7f41441d69b3bb3fbfb22868ed08a609089a48b630f3d482904d7b0')
b2sums=('0e7b8345557babd8accb74f3b97f5bcb4f089bf606703b048713870f9f9757276829bbd0287ec2d1353ed52d47271c99e3ce5e59aa70a84282114cc708441627')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCONFIG_QT6=ON
    -S $pkgname-${pkgname}_${pkgver//./_}
    -Wno-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

package() {
  depends+=(
    alsa-lib libasound.so
    aubio libaubio.so
    jack libjack.so
    liblo liblo.so
    libogg libogg.so
    libsamplerate libsamplerate.so
    libsndfile libsndfile.so
    libvorbis libvorbisenc.so libvorbisfile.so libvorbis.so
    lilv liblilv-0.so
    rubberband librubberband.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-${pkgname}_${pkgver//./_}/{README,README.VST} -t "$pkgdir/usr/share/doc/$pkgname/"
}
